package com.chinairi.mall.dao;

import com.chinairi.mall.controller.viewobject.OrderGoodsInfoParam;
import com.chinairi.mall.model.GoodsInfo;
import com.chinairi.mall.model.OrderGoods;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.chinairi.mall.model.OrderInfo;
import com.chinairi.mall.service.modelobject.MatServiceClassMO;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 订单商品关系表 Mapper 接口
 * </p>
 *
 * @author gsl
 * @since 2020-09-30
 */
public interface OrderGoodsMapper extends BaseMapper<OrderGoods> {

    /**
     * 插入订单表
     *
     * @param orderGoodsList
     */
    void batchInsert(@Param("orderGoodsList") List<OrderGoods> orderGoodsList);


    /**
     * 获取商品的物料id
     *
     * @param goodsDbIdList
     * @return
     */
    List<GoodsInfo> selectMatDbid(@Param("goodsDbIdList") List<String> goodsDbIdList);

    /**
     * 获取商品在某一服务中的分类
     *
     * @param goodsDbIdList 商品idList
     * @param serviceClass
     * @param flag
     * @param csDbid
     * @return
     */
    List<MatServiceClassMO> selectGoodsServiceClass(@Param("goodsDbIdList") List<String> goodsDbIdList,
                                                    @Param("serviceClass") String serviceClass,
                                                    @Param("flag") Integer flag,
                                                    @Param("csDbid") String csDbid);

    /**
     * 插入订单商品信息
     *
     * @param orderGoodsParam
     */
    void saveOrderGoods(@Param("orderGoodsParam") OrderGoodsInfoParam orderGoodsParam);


    /**
     * 根据商品id获取商品数量
     *
     * @param goodsDbIdList
     * @return
     */
    List<GoodsInfo> selectGoodsNum(@Param("goodsDbIdList") List<String> goodsDbIdList);


    /**
     * 更新商品库存和销量
     *
     * @param goodsInfoList
     */
    void batchUpdateGoodsNum(@Param("goodsInfoList") List<GoodsInfo> goodsInfoList);

    /**
     * 根据订单id获取订单下的商品
     * @param orderId
     * @return
     */
    List<OrderGoods> getByOrderId(String orderId);
}
